﻿Imports DotNetNuke

Namespace DotNetNuke.Modules.ActiveForums
    Partial Public Class af_usersonline
        Inherits ForumBase
#Region "Public Members"
        Public DisplayMode As String
        Public pid As Integer = 0
#End Region
#Region "Private Members"
        Private intGuestCount As Integer = 0
        Private intMemberCount As Integer = 0
#End Region
#Region "Event Handlers"
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Try
                'cbUsersOnline.PostURL = Page.ResolveUrl("~/DesktopModules/activeforums/cb.aspx")
                'cbUsersOnline.Parameter = "uo|" & PortalId.ToString & "|" & ModuleId.ToString & "|" & Me.UserId.ToString
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "amaf_uo", "setInterval('amaf_uo()',50000);", True)
                Dim bolShow As Boolean = True
                If Not Request.Cookies("WHOSShow") Is Nothing Then
                    bolShow = CType(Request.Cookies("WHOSShow").Value, Boolean)
                End If

                If bolShow Then
                    DisplayMode = " style=""display:block;"""
                Else
                    DisplayMode = " style=""display:none;"""
                End If
                BindUsersOnline()
                'hidUserId.Value = CStr(Me.UserId)
            Catch ex As Exception
                DotNetNuke.Services.Exceptions.ProcessModuleLoadException(Me, ex)
            End Try

        End Sub
#End Region

#Region "Private Methods"
        Private Sub BindUsersOnline()
            Dim uo As New UsersOnline
            Dim sOnlineList As String = uo.GetUsersOnline(PortalId, ModuleId, UserId)
            Dim dr As IDataReader = DataProvider.Instance.Profiles_GetStats(PortalId, -1, 2)
            Dim anonCount As Integer = 0
            Dim memCount As Integer = 0
            Dim memTotal As Integer = 0
            While dr.Read
                anonCount = CInt(dr("Guests"))
                memCount = CInt(dr("Members"))
                memTotal = CInt(dr("MembersTotal"))
            End While
            dr.Close()
            Dim sGuestsOnline As String
            Dim sUsersOnline As String
            sGuestsOnline = Utilities.GetSharedResource("[RESX:GuestsOnline]")
            sUsersOnline = Utilities.GetSharedResource("[RESX:UsersOnline]")
            litGuestsOnline.Text = Replace(sGuestsOnline, "[GUESTCOUNT]", anonCount.ToString)
            sUsersOnline = Replace(sUsersOnline, "[USERCOUNT]", memCount.ToString)
            sUsersOnline = Replace(sUsersOnline, "[TOTALMEMBERCOUNT]", memTotal.ToString)
            litUsersOnline.Text = sUsersOnline & " " & sOnlineList
        End Sub

#End Region


    End Class
End Namespace
